
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Jesus
 */
public class Logger {



    public void log(String ip,String tipo, String exito)
    {
        try
        {
            DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
            Date date = new Date();

//            FileWriter fstream = new FileWriter("logs.txt");
//            BufferedWriter out = new BufferedWriter(fstream);
//            out.write(ip+" - "+tipo+" - "+dateFormat.format(date)+" - "+exito);
//            out.close();

            FileWriter ficheroR = new FileWriter("logs.txt",true);
            PrintWriter escritor = new PrintWriter(ficheroR);

            escritor.println(ip + " - " + tipo + " - " +dateFormat.format(date) + " - " + exito);

            escritor.close();
            ficheroR.close();

        }catch (Exception e)
        {
            System.err.println("Error: " + e.getMessage());
        }
    }

}
